home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / c_lib01.arc / FRAME.C < prev    next >
Text File  |  1985-10-16  |  3KB  |  88 lines

  1. /*                             *** frame.c ***                       */
  2. /*                                                                   */
  3. /* IBM-PC microsoft "C" under PC-DOS                                 */
  4. /*                                                                   */
  5. /* Function to draw a box given the upper left corner and the lower  */
  6. /* right corner.  Uses the extended character set - graphics board   */
  7. /* not needed.  Uses direct BIOS calls.  Returns a 0 if successful   */
  8. /* or a -1 if invalid parameters.                                    */
  9. /*                                                                   */
  10. /* *** NOTE ***                                                      */
  11. /* The upper left corner of the screen is 0,0 and the bottom right   */
  12. /* corner is 24,79.                                                  */
  13. /*                                                                   */
  14. /* Written by L. Cuthbertson, May 1984.                              */
  15. /*                                                                   */
  16. /*********************************************************************/
  17. /*                                                                   */
  18. /* Added the nlines argument.  If = 1, single line frame.            */
  19. /* If = 2, double line frame.                                        */
  20. /* Lew Paper, 7/4/85                                                 */
  21.  
  22. #include "dispio.h"
  23.  
  24. #define biosset CURPOS
  25. #define bioswc(char, n) write_ch(char, PAGE, n)
  26.  
  27. int dispio(), write_ch();
  28.  
  29. int frame(ulrow,ulcol,lrrow,lrcol, nlines)
  30. int ulrow,ulcol,lrrow,lrcol, nlines;
  31. {
  32.         static int horbar[2] = {0xC4, 0xCD};
  33.         static int verbar[2] = {0xB3, 0xBA};
  34.         static int ulcorn[2] = {0xDA, 0xC9};
  35.         static int urcorn[2] = {0xBF, 0xBB};
  36.         static int llcorn[2] = {0xC0, 0xC8};
  37.         static int lrcorn[2] = {0xD9, 0xBC};
  38.         int count,irow;
  39.         int ndx, verchar;
  40.  
  41.         /* error checking */
  42.         if (ulrow < 0 || ulrow > 24) return(-1);
  43.         if (ulcol < 0 || ulcol > 79) return(-1);
  44.         if (lrrow < 0 || lrrow > 24) return(-1);
  45.         if (lrcol < 0 || lrcol > 79) return(-1);
  46.         if (lrrow < ulrow) return(-1);
  47.         if (lrcol < ulcol) return(-1);
  48.         if (nlines < 1 || nlines > 2) return(-1);
  49.         
  50.         ndx = nlines - 1;
  51.         verchar = verbar[ndx];
  52.  
  53.         /* do top line first */
  54.         biosset(ulrow,ulcol);
  55.         bioswc(ulcorn[ndx],1);
  56.         count = lrcol-ulcol-1;
  57.         if (count > 0) {
  58.                 biosset(ulrow,ulcol+1);
  59.                 bioswc(horbar[ndx],count);
  60.         }
  61.         biosset(ulrow,lrcol);
  62.         bioswc(urcorn[ndx],1);
  63.  
  64.         /* do both sides at once */
  65.         irow = ulrow + 1;
  66.         while (irow < lrrow) {
  67.                 biosset(irow,ulcol);
  68.                 bioswc(verchar,1);
  69.                 biosset(irow,lrcol);
  70.                 bioswc(verchar,1);
  71.                 irow++;
  72.         }
  73.  
  74.         /* do bottom line */
  75.         biosset(lrrow,ulcol);
  76.         bioswc(llcorn[ndx],1);
  77.         count = lrcol-ulcol-1;
  78.         if (count > 0) {
  79.                 biosset(lrrow,ulcol+1);
  80.                 bioswc(horbar[ndx],count);
  81.         }
  82.         biosset(lrrow,lrcol);
  83.         bioswc(lrcorn[ndx],1);
  84.  
  85.         /* done */
  86.         return(0);
  87. }
  88.